﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.Supervise.Model;
using HZ.Supervise.Model.Enum;

namespace HZ.Supervise.Web.Message
{
    public partial class MessageListForType7 : BasePage
    {
        IBLL.IBLL_MessageTypeDetail ibllMessage = new BLL.BLL_MessageTypeDetail();

        public MessageListForType7()
        {
            this.ModuleNo = Module.预警处理.ToString();
            this.PageOperateType = OperateType.医院已入库未回款.ToString();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindList1();
            }
        }


        void BindList1()
        {
          
            int count = 0;

            Model.MessageSend messSend = new MessageSend();
            messSend.UserId = CurrentAccount.UserID.ToString();
            messSend.TypeId = 7;

            if (Request.QueryString["Is_Read"] == "1")//已读
            {
                gvwMessageDetailList.DataSource = ibllMessage.GetDetailMessagSendNew(messSend, 1, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out count);
                gvwMessageDetailList.DataBind();
                AspNetPager1.RecordCount = count;
            }
            else
            {
                gvwMessageDetailList.DataSource = ibllMessage.GetDetailMessagSendNew(messSend, 0, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out count);
                gvwMessageDetailList.DataBind();
                AspNetPager1.RecordCount = count;
            }
        }

        /// <summary>
        /// 绑定列表
        /// </summary>
        void BindList()
        {

            //int count = 0;
            //Model.MessageTypeDetail messType = new MessageTypeDetail();
            //messType.UserId = CurrentAccount.UserID.ToString();
            //messType.TypeId = 7;
            //messType.Is_Del = false;
            //messType.Is_Work = true;

            //if (Request.QueryString["Is_Read"] != "0")//已读
            //{
            //    gvwMessageList.DataSource = ibllMessage.GetMessageType(messType, 1, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out count);
            //    gvwMessageList.DataBind();
            //    AspNetPager1.RecordCount = count;
            //}
            //else//未读
            //{
            //    gvwMessageList.DataSource = ibllMessage.GetMessageType(messType, 0, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out count);
            //    gvwMessageList.DataBind();
            //    AspNetPager1.RecordCount = count;
            //}
        }

        protected void gvwMessageList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //if (e.CommandName == "DirectByDetail")
            //{
            //    GridViewRow row = ((Control)e.CommandSource).NamingContainer as GridViewRow;
            //    string _strMessDetailId = e.CommandArgument.ToString();
            //    ibllMessage.SetMessageIsRead(_strMessDetailId);//设置此消息为已读
            //    Response.Redirect("MessageCompanyDetailForType7.aspx?MessageDetailId=" + _strMessDetailId);
            //}
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindList1();
        }

        protected void btnDelte_Click(object sender, EventArgs e)
        {

        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            AspNetPager1.CurrentPageIndex = 1;
            BindList1();
        }


        protected void gvwMessageDetailList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DirectByDetail")
            {
                GridViewRow row = ((Control)e.CommandSource).NamingContainer as GridViewRow;
                string _strCompanyId = e.CommandArgument.ToString();
                string _strMessageId = Convert.ToString(this.gvwMessageDetailList.DataKeys[row.RowIndex].Value);
                ibllMessage.SetMessageIsRead(_strMessageId);//设置此消息为已读
                Response.Redirect("MessageFinalDetailForType7.aspx?CompanyId=" + _strCompanyId + "&MessDetailId=" + _strMessageId);
            }
        }
    }
}
